#define _CRT_SECURE_NO_WARNINGS 1
#include"string.h"

namespace ST
{
	void test_string1()
	{
		string s1;
		cout << s1.c_str() << endl;
		string s2("hello world");
		cout << s2.c_str() << endl;

		for (size_t i = 0; i < s2.size(); ++i)
		{
			s2[i]++;
		}
		cout << s2.c_str() << endl;
		for (auto ch : s2)
		{
			cout << ch << " ";
		}
		cout << endl;
		string::iterator it1 = s1.begin();
		while (it1 != s1.end())
		{
			cout << *it1 << " ";
			++it1;
		}
		cout << endl;

		const string s3("hello world");
		string::const_iterator it3 = s3.begin();
		while (it3 != s3.end())
		{
			cout << *it3 << " ";
			++it3;
		}
		cout << endl;
	}
	void test_string2()
	{
		string s1("hello world");
		s1.push_back('x');
		cout << s1 << endl;
		s1.append("hello cpp");
		cout << s1 << endl;

		s1 += 'y';
		s1 += "zzzzz";
		cout << s1.c_str() << endl<< endl;

	}

	void test_string3()
	{
		string s1("hello world");
		s1.insert(6, 'x');
		cout << s1<<endl;

		s1.insert(0, 'x');
		cout << s1 << endl;
		string s2("xixibuxixi");
		s2.insert(6, "xxx");
		cout << s2 << endl;

		string s3("buxixi");
		s3.erase(4);
		cout << s3;
	}

	void split_url(const string& ur1)
	{
		size_t i1 = ur1.find(':');
		if (i1 != string::npos)
		{
			string s = ur1.substr(0, i1);
			cout << s<<endl;
		}
	}
	void test_string4()
	{
		string url1 = "http://legacy.cplusplus.com/reference/string/string/";
		//string url2 = "https://yuanbao.tencent.com/chat/naQivTmsDa/43735652-b5e3-11ef-bcaa-c6162ee89a56?yb_channel=3003";
		//string url3 = "https://legacy.cplusplus.com/reference/vector/vector/";

		split_url(url1);
		//split_url(url2);
		//split_url(url3);
	}
}


#include<vector>

//int main()
//{
//	//ST::test_string4();
//	vector<int> v1;
//	v1.push_back(1);
//	v1.push_back(2);
//	v1.push_back(3);
//	v1.push_back(4);
//
//	vector<int> v2(10, 1);
//
//	vector<int> v3(v1.begin(), v1.end());
//	for (size_t i = 0; i < v1.size(); i++)
//	{
//		cout << v1[i] << " ";
//	}
//	cout << endl;
//	for (auto e : v2)
//	{
//		cout << e << " ";
//	}
//	cout << endl;
//
//	vector<int>::iterator it = v3.begin();
//	while (it != v3.end())
//	{
//		cout << *it << " ";
//		++it;
//	}
//	cout << endl;
//	return 0;
//}

int main()
{
	vector<int> v1;
	v1.reserve(100);
	size_t old = v1.capacity();
	cout << old << endl;
	for (size_t i = 0; i < 100; i++)
	{
		v1.push_back(i);
		if (v1.capacity() != old)
		{
			cout << v1.capacity() << endl;
			old = v1.capacity();
		}
	}
	v1.insert(v1.begin(), 1000);
	v1.insert(v1.begin() + 3, 1000);
	for (auto e : v1)
	{
		cout << e << " ";
	}
	cout << endl;

	auto it = find(v1.begin(), v1.end(), 5);
	if (it != v1.end())
	{
		v1.insert(it, 50);
	}
	for (auto e : v1)
	{
		cout << e << " ";
	}
	cout << endl;


	v1.erase(v1.begin());
	for (auto e : v1)
	{
		cout << e << " ";
	}
	cout << endl;

	int x;
	cin >> x;
	it = find(v1.begin(), v1.end(), x);
	if (it != v1.end())
	{
		v1.erase(it);
	}
	for (auto e : v1)
	{
		cout << e << ",";
	}
	cout << endl;

		
}
